#include <iostream>
#include <vector>

using namespace std;

void quickSort(vector<int>& nums, int left, int right);

int main(){
	vector<int> nums = {5,3,6,2,8,8,3,2,4,1,0,0,3,4,2,4};
	quickSort(nums, 0, nums.size()-1);
	for(int i = 0; i < nums.size(); ++i)
		cout << nums[i] << "  ";
	cout << endl;
	return 0;
}

void quickSort(vector<int>& nums, int left, int right){
	if(left >= right) return;
	int o_left = left, o_right = right;
	int pivot = nums[left];
	while(left < right){
		while(nums[right] >= pivot && left < right) --right;
		nums[left] = nums[right];
		while(nums[left] < pivot && left < right) ++left;
		nums[right] = nums[left];
	}
	nums[left] = pivot;
	quickSort(nums, o_left, left-1);
	quickSort(nums, left+1, o_right);
}